package MaintMenu.VenPricingUpdTBLN;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Created with IntelliJ IDEA.
 * User: Jason
 * Date: 8/8/13
 * Time: 7:00 PM
 * To change this template use File | Settings | File Templates.
 */
public class delTblnCost {
    int x=0;      
    int cc=0;
    public  delTblnCost(){

        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection conli = DriverManager.getConnection(dbURL, "", "");
            Statement delPrice = conli.createStatement();
            String st[] = new String[13];

             st[0]="update  tblbcn set protec_p=0, tyg_tw_p=0,tyg_tx_p=0, gd_p=0, protec_k=0, tyg_tw_k=0,tyg_tx_k=0, gd_k=0, protec_c=0, tyg_tw_c=0,tyg_tx_c=0, gd_c=0";
             st[1]="update  tblhfn set tyg_tx_p=0, tyg_tw_p=0, gd_p=0,tyg_tx_k=0, tyg_tw_k=0, gd_k=0,tyg_tx_c=0, tyg_tw_c=0, gd_c=0";
             st[2]="update  tblotn set protec_p=0,tyg_tx_p=0, tyg_tw_p=0, gd_p=0,fey_p=0,protec_k=0,tyg_tx_k=0, tyg_tw_k=0, gd_k=0,fey_k=0,protec_c=0,tyg_tx_c=0, tyg_tw_c=0, gd_c=0,fey_c=0";
             st[3]="update  tblcln set tyg_tx_p=0, tyg_tw_p=0, gd_p=0, gn_p=0,depo_p=0,tyg_tx_k=0, tyg_tw_k=0, gd_k=0, gn_k=0,depo_k=0,tyg_tx_c=0, tyg_tw_c=0, gd_c=0, gn_c=0,depo_c=0";
             st[4]="update  tblmrn set tyg_tx_p=0, tyg_tw_p=0, gd_p=0, gn_p=0,depo_p=0, ks_p=0,kv_p=0, tyg_tx_k=0, tyg_tw_k=0, gd_k=0, gn_k=0,depo_k=0, ks_k=0,kv_k=0,tyg_tx_c=0, tyg_tw_c=0, gd_c=0, gn_c=0,depo_c=0, ks_c=0,kv_c=0";
             st[5]="update  tblltn set genera_p=0, depo_p=0, ee_p=0, gd_p=0, genera_k=0, depo_k=0, ee_k=0, gd_k=0,genera_c=0, depo_c=0, ee_c=0, gd_c=0";


             st[6]="update  tblbcn_tempout2 set protec_p=0, tyg_tw_p=0,tyg_tx_p=0, gd_p=0, protec_k=0, tyg_tw_k=0,tyg_tx_k=0, gd_k=0, protec_c=0, tyg_tw_c=0,tyg_tx_c=0, gd_c=0";
             st[7]="update  tblhfn_tempout2 set tyg_tx_p=0, tyg_tw_p=0, gd_p=0, tyg_tx_k=0, tyg_tw_k=0, gd_k=0,tyg_tx_c=0, tyg_tw_c=0, gd_c=0";
             st[8]="update  tblotn_tempout2 set protec_p=0,tyg_tx_p=0, tyg_tw_p=0, gd_p=0,fey_p=0,protec_k=0,tyg_tx_k=0, tyg_tw_k=0, gd_k=0,fey_k=0, protec_c=0,tyg_tx_c=0, tyg_tw_c=0, gd_c=0,fey_c=0";
             st[9]="update  tblcln_tempout2 set tyg_tx_p=0, tyg_tw_p=0, gd_p=0, gn_p=0,depo_p=0,tyg_tx_k=0, tyg_tw_k=0, gd_k=0, gn_k=0,depo_k=0,tyg_tx_c=0, tyg_tw_c=0, gd_c=0, gn_c=0,depo_c=0";
             st[10]="update  tblmrn_tempout2 set tyg_tx_p=0, tyg_tw_p=0, gd_p=0, gn_p=0,depo_p=0, ks_p=0,kv_p=0,tyg_tx_k=0, tyg_tw_k=0, gd_k=0, gn_k=0,depo_k=0, ks_k=0,kv_k=0,tyg_tx_c=0, tyg_tw_c=0, gd_c=0, gn_c=0,depo_c=0, ks_c=0,kv_c=0";
             st[11]="update  tblltn_tempoutbk2 set gn_p=0, depo_p=0, ee_p=0,gn_k=0, depo_k=0, ee_k=0";              //no _c for lights
             st[12]="update TBLLTN_TEMPOUTLI2 set gn_p=0, depo_p=0, ee_p=0,gn_k=0, depo_k=0, ee_k=0";               //no _c for lights





//            st[0]="update  tblbcn_tempout2 set protec_p=0, tyg_tw_p=0,tyg_tx_p=0, gd_p=0";
//
//            st[1]="update  tblhfn_tempout2 set tyg_tx_p=0, tyg_tw_p=0, gd_p=0";
//
//            st[2]="update  tblotn_tempout2 set protec_p=0,tyg_tx_p=0, tyg_tw_p=0, gd_p=0,fey_p=0";
//
//            st[3]="update  tblcln_tempout2 set tyg_tx_p=0, tyg_tw_p=0, gd_p=0, gn_p=0,depo_p=0";
//
//            st[4]="update  tblmrn_tempout2 set tyg_tx_p=0, tyg_tw_p=0, gd_p=0, gn_p=0,depo_p=0, ks_p=0,kv_p=0";
//
//            st[5]="update  tblltn_tempoutbk2 set gn_p=0, depo_p=0, ee_p=0;";
//
//            st[6]="update TBLLTN_TEMPOUTLI2 set gn_p=0, depo_p=0, ee_p=0;";
//
            for (x=0; x<st.length;x++){
                Statement stli = conli.createStatement();

                try {

//                    System.out.println("Script :"+st[x]);
                    int rowsupdated = stli.executeUpdate(st[x]);
                    stli.execute(st[x]);          //delete 2nd time using stli.execute intead of executeUpdate
//                    System.out.print("TRU : "+rowsupdated+"\t");
                    //JOptionPane.showOptionDialog(null, "Statement : " + st[x] + "\n\nTotal record Updated : " + rowsupdated, "Update Complete", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new Object[]{}, null);
                    cc++;
                    if (cc==4){
//                        System.out.println("");
                        cc=0;
                    }


                }catch(SQLException er) {
                    er.printStackTrace();
                }stli.close();
            }
//            System.out.println(sql);
//             st[0]=(sql);




        } catch (ClassNotFoundException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            System.out.println(e);
        } catch (SQLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            System.out.println(e);
        }
    }

}
